<template>
  <div>
    <FilterTable
      ref="table"
      columnsRef="ygy_repairProject"
      :dataSource="dataSource"
      :isSelectColumn="false"
      :columns="columns"
      :datakey="'rows'"
      height="auto"
      :onColumnsChange="columns => (this.columns = columns)"
    >
    </FilterTable>
  </div>
</template>

<script>
import { dictionary } from '@/utils/dictMixin';
import { getAllUser } from '@/api/customerRepair/activityVisit/resultEntry'; // 查询所有用户
import moment from 'moment';
// import { getAllRepairPart } from '@/api/repair/repairManage/repairFeeQuery';
export default {
  name: 'repairProject',
  mixins: [dictionary],
  props: ['rowData', 'roNo', 'allUser', 'chargePartition', 'dataSource'],
  data() {
    return {
      columns: this.createTable()
      // fetchApi: getAllRepairPart,
      // fetchParams: {}
    };
  },
  created() {
    let roNo = this.roNo;
    this.fetchParams = Object.assign({}, { roNo: roNo, ownerCode: this.rowData.ownerCode }, { xhrAbort: false });
  },
  mounted() {
    this.columns.find(item => item.dataIndex === 'sender').dictItems = this.allUser;
    this.columns.find(item => item.dataIndex === 'sender').filterItems = this.allUser;
    this.columns.find(item => item.dataIndex === 'receiver').dictItems = this.allUser;
    this.columns.find(item => item.dataIndex === 'receiver').filterItems = this.allUser;
    this.columns.find(x => x.dataIndex === 'chargePartitionCode').dictItems = this.chargePartition;
    this.columns.find(x => x.dataIndex === 'chargePartitionCode').filterItems = this.chargePartition;
  },
  methods: {
    createTable() {
      return [
        {
          title: '序号',
          dataIndex: 'index',
          width: 70,
          sorter: true,
          render: props => {
            return <span>{props.row.index + 1}</span>;
          }
        },
        {
          title: '收费区分',
          dataIndex: 'chargePartitionCode',
          sorter: true
        },

        {
          title: '仓库代码',
          dataIndex: 'storageCode',
          sorter: true
        },
        {
          title: '配件代码',
          dataIndex: 'partNo',
          sorter: true
        },
        {
          title: '配件名称',
          dataIndex: 'partName',
          sorter: true,
          editable: false,
          editType: 'text'
        },
        {
          title: '是否主要配件',
          dataIndex: 'isMainPart',
          sorter: true,
          render: props => {
            return <span>{this.createDictText(props.row.isMainPart, '1004')}</span>;
          }
        },
        {
          title: '配件数量',
          dataIndex: 'partQuantity',
          sorter: true
        },
        {
          title: '计量单位',
          dataIndex: 'unitName',
          sorter: true
        },
        {
          title: '配件销售单价',
          dataIndex: 'partSalesPrice',
          sorter: true,
          initialValue: '0'
        },
        {
          title: '配件销售金额',
          dataIndex: 'partSalesAmount',
          sorter: true,
          precision: 2
        },
        {
          title: '配件成本单价',
          dataIndex: 'partCostPrice',
          summationPrecision: 2,
          sorter: true
        },
        {
          title: '配件成本金额',
          dataIndex: 'partCostAmount',
          sorter: true
        },
        {
          title: '优惠金额',
          dataIndex: 'discountAmount',
          sorter: true,
          precision: 2
        },
        {
          title: '折扣率',
          dataIndex: 'discount',
          sorter: true
        },
        {
          title: '实收金额',
          dataIndex: 'realAmount',
          sorter: true,
          precision: 2
        },
        {
          title: '是否入账',
          dataIndex: 'isFinished',
          sorter: true,
          render: props => {
            return <span>{this.createDictText(props.row.isFinished, '1004')}</span>;
          }
        },
        {
          title: '发料人',
          dataIndex: 'sender',
          sorter: true
        },
        {
          title: '是否增项',
          dataIndex: 'isAddition',
          sorter: true,
          render: props => {
            // return <span>{this.createDictText(props.row.IS_ADDITION, '1004')}</span>;
            return <el-checkbox checked={props.row.isAddition == 10041001} disabled></el-checkbox>;
          }
        },
        {
          title: '领料人',
          dataIndex: 'receiver',
          sorter: true
        },
        {
          title: '是否不修',
          dataIndex: 'needlessRepair',
          sorter: true,
          render: props => {
            return <span>{this.createDictText(props.row.needlessRepair, '1004')}</span>;
          }
        },
        {
          title: '不修原因',
          dataIndex: 'needlessReason'
        },
        {
          title: '维修项目代码',
          dataIndex: 'labourCode',
          sorter: true
        },
        {
          title: '活动编号',
          dataIndex: 'activityCode',
          sorter: true
        }
      ];
    }
  }
};
</script>

<style lang="less"></style>
